//
//  HMVisitorViewController.swift
//  weibo
//
//  Created by LCH on 16/3/4.
//  Copyright © 2016年 lch. All rights reserved.
//

import UIKit

class HMVisitorViewController: UITableViewController {

    var userLogin: Bool = HMUserAccountViewModel.sharedAccountViewModel.userLogon
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        if userLogin {
        
            super.loadView()
        
        }else {
        
         setupVisitorView()
            
        }
      }
    private func setupVisitorView(){
    
     view = visitorView
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", target: self, action: "login")
        
    navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "登录", target: self, action: "login")
    
    }
   @objc private func login() {
    
      let vc = HMOAuthViewController()
    
    presentViewController(HMNavigationController(rootViewController:vc), animated: true, completion: nil)
    
    }
    
    
    
    
    
  lazy var visitorView: HMVisitorView = {
    
     let v = HMVisitorView()
        
     v.delegate = self
     
    return v
    
    }()
    
  

}
    

extension HMVisitorViewController:HMVisitorViewDelegate {
    
    
    func visitorView(visitorView: HMVisitorView, loginBtnDidClick: UIButton) {
        
      login()
    
    }
    
    
   
}

